﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;
using Models;
using System.Web.Script.Serialization;

namespace 公司CRM客户关系系统.Sale
{
    /// <summary>
    /// saleManager 的摘要说明
    /// </summary>
    public class saleManager : IHttpHandler, System.Web.SessionState.IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            string action = context.Request["action"];
            if (action == "paging")
            {
                int pageIndex = int.Parse(context.Request["pageIndex"]);
                int pageSize = int.Parse(context.Request["pageSize"]);

                PagingList<V_Chances> list = BaseDAL.Paging<V_Chances>(pageSize, pageIndex,false);

                JavaScriptSerializer jss = new JavaScriptSerializer();
                string json = jss.Serialize(new { total = list.RecordCount, data = list });
                context.Response.Write(json);

            }
            if (action == "byid")
            {
                int id = int.Parse(context.Request.QueryString["id"]);
                //查询
                Chances c = BaseDAL.Find<Chances>(id);
                //转为json
                JavaScriptSerializer jss = new JavaScriptSerializer();
                string json = jss.Serialize(c);
                //输出结果
                context.Response.Write(json);

            }

        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}